package com.yz.newspaper.exception;


import com.yz.newspaper.pojo.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//全局异常处理器
@Slf4j
@RestControllerAdvice
public class GlobalException {
    @ExceptionHandler(Exception.class)//捕获所有异常
    public Result ex(Exception ex) {
        log.info("异常信息打印{}", ex);
        ex.printStackTrace();
        return Result.error("服务异常");
    }
}

